package com.blb.mapper;

import com.blb.entity.Warning;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author ZhengSainan
 * @since 2019-11-21
 */
public interface WarningMapper extends BaseMapper<Warning> {
    /**
     * 查询小于预警值的数据信息
     * @return
     */
    public List<Map<String ,Object>> getWarningMessage(int start,int length,String ware,String product,String companyId);

    /**
     * 查询信息条数
     * @return
     */
    public int warningMessageCount(String ware,String product,String companyId);

    /**
     * 查询仓库
     * @return
     */
    @Select("SELECT ware_name FROM t_ware")
    public List<String> getWare(String companyId);

    /**
     * 更新预警值
     * @param warning
     */
    @Select("update t_warning set warning_num=#{warningNum} where warehouse_id=#{warehouseId} and product_id=#{productId}")
    public void updateWarningNum(Warning warning);

    /**
     * 查询所有商品
     * @param companyId
     * @return
     */
    @Select("SELECT product_no,product,ware_id,company_id,`status`,COUNT(*)FROM t_cargo  GROUP BY product_no HAVING `status`='有货' AND company_id=#{companyId}")
    public List<Map<String ,Object>> getProduct(String companyId);

    /**
     * 查询当前仓库所有信息
     * @param companyId
     * @return
     */
    @Select("SELECT ware_no,id,ware_name,company_id FROM t_ware WHERE company_id=#{companyId} ")
    public List<Map<String,Object>> getWareId(String companyId);
}
